package com.shujia.spark.mllib

import java.io.StringReader

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import scala.collection.mutable.ListBuffer

object IK {

  def fit(str: String): List[String] ={

    val words = new ListBuffer[String]

    val reader = new StringReader(str)

    val segmenter = new IKSegmenter(reader,true)

    var lexeme: Lexeme = segmenter.next()

    while (lexeme != null){
      val word: String = lexeme.getLexemeText

      words += word

      lexeme = segmenter.next()
    }
    words.toList

  }

}
